package com.ruanyun.sys.modular.system.controller;

import com.ruanyun.base.pojo.page.LayuiPageInfo;
import com.ruanyun.sys.modular.system.entity.Stations;
import com.ruanyun.sys.modular.system.model.params.StationsParam;
import com.ruanyun.sys.modular.system.service.StationsService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 岗位控制器
 *
 * @author wangchuan
 * @Date 2019-08-15 09:20:15
 */
@Controller
@RequestMapping("/stations")
public class StationsController extends BaseController {

    private String PREFIX = "/modular/system/stations";

    @Autowired
    private StationsService stationsService;

    /**
     * 跳转到主页面
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/stations.html";
    }

    /**
     * 新增页面
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/stations_add.html";
    }

    /**
     * 编辑页面
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/stations_edit.html";
    }

    /**
     * 新增接口
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(StationsParam stationsParam) {
        this.stationsService.add(stationsParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(StationsParam stationsParam) {
        this.stationsService.update(stationsParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(StationsParam stationsParam) {
        this.stationsService.delete(stationsParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(StationsParam stationsParam) {
        Stations detail = this.stationsService.getById(stationsParam.getStationsId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author wangchuan
     * @Date 2019-08-15
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(StationsParam stationsParam) {
        return this.stationsService.findPageBySpec(stationsParam);
    }

    /**
     * 查询所有职位
     *
     * @author administrator
     * @Date 2019-03-13
     */
    @ResponseBody
    @RequestMapping("/listStations")
    public LayuiPageInfo listlistStationsTypes(@RequestParam(value = "userId", required = false) Long userId) {
        return this.stationsService.listStations(userId);
    }

}


